﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;

using CarFrameWork.Common;

namespace CarFrameWork.Model
{
	/// <summary>
	/// 类ParameSystem。
	/// </summary>
	[Serializable]
	public partial class ParameSystem
	{
        #region Model
        private string _ftpip;
        private string _ftpusername;
        private string _ftppassword;
        private string _ugpath;
        private string _caepath;
        /// <summary>
        /// 
        /// </summary>
        public string ftpIp
        {
            set { _ftpip = value; }
            get { return _ftpip; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ftpUserName
        {
            set { _ftpusername = value; }
            get { return _ftpusername; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ftpPassWord
        {
            set { _ftppassword = value; }
            get { return _ftppassword; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string ugPath
        {
            set { _ugpath = value; }
            get { return _ugpath; }
        }
        /// <summary>
        /// 
        /// </summary>
        public string caePath
        {
            set { _caepath = value; }
            get { return _caepath; }
        }
        #endregion Model


        #region  Method

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ParameSystem()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ftpIp,ftpUserName,ftpPassWord,ugPath,caePath ");
            strSql.Append(" FROM [ParameSystem] ");
            //strSql.Append(" where 条件);
            SqlParameter[] parameters = {
};

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ftpIp"] != null && ds.Tables[0].Rows[0]["ftpIp"].ToString() != "")
                {
                    this.ftpIp = ds.Tables[0].Rows[0]["ftpIp"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ftpUserName"] != null && ds.Tables[0].Rows[0]["ftpUserName"].ToString() != "")
                {
                    this.ftpUserName = ds.Tables[0].Rows[0]["ftpUserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ftpPassWord"] != null && ds.Tables[0].Rows[0]["ftpPassWord"].ToString() != "")
                {
                    this.ftpPassWord = ds.Tables[0].Rows[0]["ftpPassWord"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ugPath"] != null && ds.Tables[0].Rows[0]["ugPath"].ToString() != "")
                {
                    this.ugPath = ds.Tables[0].Rows[0]["ugPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["caePath"] != null && ds.Tables[0].Rows[0]["caePath"].ToString() != "")
                {
                    this.caePath = ds.Tables[0].Rows[0]["caePath"].ToString();
                }
            }
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select count(1) from [ParameSystem]");
            //strSql.Append(" where 条件);

            SqlParameter[] parameters = {
};

            return DbHelperSQL.Exists(strSql.ToString(), parameters);
        }


        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into [ParameSystem] (");
            strSql.Append("ftpIp,ftpUserName,ftpPassWord,ugPath,caePath)");
            strSql.Append(" values (");
            strSql.Append("@ftpIp,@ftpUserName,@ftpPassWord,@ugPath,@caePath)");
            SqlParameter[] parameters = {
					new SqlParameter("@ftpIp", SqlDbType.NVarChar,50),
					new SqlParameter("@ftpUserName", SqlDbType.NVarChar,50),
					new SqlParameter("@ftpPassWord", SqlDbType.NVarChar,50),
					new SqlParameter("@ugPath", SqlDbType.NVarChar,200),
					new SqlParameter("@caePath", SqlDbType.NChar,200)};
            parameters[0].Value = ftpIp;
            parameters[1].Value = ftpUserName;
            parameters[2].Value = ftpPassWord;
            parameters[3].Value = ugPath;
            parameters[4].Value = caePath;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update [ParameSystem] set ");
            strSql.Append("ftpIp=@ftpIp,");
            strSql.Append("ftpUserName=@ftpUserName,");
            strSql.Append("ftpPassWord=@ftpPassWord,");
            strSql.Append("ugPath=@ugPath,");
            strSql.Append("caePath=@caePath");
            //strSql.Append(" where 条件);
            SqlParameter[] parameters = {
					new SqlParameter("@ftpIp", SqlDbType.NVarChar,50),
					new SqlParameter("@ftpUserName", SqlDbType.NVarChar,50),
					new SqlParameter("@ftpPassWord", SqlDbType.NVarChar,50),
					new SqlParameter("@ugPath", SqlDbType.NVarChar,200),
					new SqlParameter("@caePath", SqlDbType.NChar,200)};
            parameters[0].Value = ftpIp;
            parameters[1].Value = ftpUserName;
            parameters[2].Value = ftpPassWord;
            parameters[3].Value = ugPath;
            parameters[4].Value = caePath;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from [ParameSystem] ");
            //strSql.Append(" where 条件);
            SqlParameter[] parameters = {
};

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
            if (rows > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }


        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void GetModel()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select ftpIp,ftpUserName,ftpPassWord,ugPath,caePath ");
            strSql.Append(" FROM [ParameSystem] ");
            //strSql.Append(" where 条件);
            SqlParameter[] parameters = {
};

            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ftpIp"] != null && ds.Tables[0].Rows[0]["ftpIp"].ToString() != "")
                {
                    this.ftpIp = ds.Tables[0].Rows[0]["ftpIp"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ftpUserName"] != null && ds.Tables[0].Rows[0]["ftpUserName"].ToString() != "")
                {
                    this.ftpUserName = ds.Tables[0].Rows[0]["ftpUserName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ftpPassWord"] != null && ds.Tables[0].Rows[0]["ftpPassWord"].ToString() != "")
                {
                    this.ftpPassWord = ds.Tables[0].Rows[0]["ftpPassWord"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ugPath"] != null && ds.Tables[0].Rows[0]["ugPath"].ToString() != "")
                {
                    this.ugPath = ds.Tables[0].Rows[0]["ugPath"].ToString();
                }
                if (ds.Tables[0].Rows[0]["caePath"] != null && ds.Tables[0].Rows[0]["caePath"].ToString() != "")
                {
                    this.caePath = ds.Tables[0].Rows[0]["caePath"].ToString();
                }
            }
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * ");
            strSql.Append(" FROM [ParameSystem] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(strSql.ToString());
        }

        #endregion  Method
	}
}

